package com.thprojects.myphotomemories.view.components;

import android.content.Context;
import android.view.View;

import com.thprojects.myphotomemories.R;

public class Dot extends View{

	public enum State {OFF, ON};
	
	int mIdx;
	State mState;
	
	public Dot(int idx, State state, Context context) {
		super(context);
		
		mIdx = idx;
		mState = state;
		
		if (state == State.OFF) turnOff();
		else turnOn();
	}
	
	public Dot(int idx, Context context) {
		super(context);		
		mIdx = idx;
		turnOff();
	}
	
	public void turnOn(){
		mState = State.ON;
		draw();
	}
	
	public void turnOff(){
		mState = State.OFF;
		draw();
	}
	
	private void draw(){
		if (mState == State.OFF){
			this.setBackgroundResource(R.drawable.dot_unsel);
		}
		else{
			this.setBackgroundResource(R.drawable.dot_sel);
		}
	}
	
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(25, 25);
		setMeasuredDimension(25, 25);
	}
	
	public int getIndex(){
		return mIdx;
	}
	
}
